/**
 * 
 */
package org.rollinitiative.d20.entity.talents;

import java.util.ArrayList;

import javax.xml.bind.annotation.*;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * This class manages the collection of skills supported by a ruleset.
 * 
 * @author bebopjmm
 * 
 * @since incr-0.1
 */
@XmlRootElement(name = "SkillCollection", namespace = "java:org.rollinitiative.d20.entity")
@XmlType(name = "SkillCollectionType", namespace = "java:org.rollinitiative.d20.entity")
public class SkillsCollection
{
   static final Log LOG = LogFactory.getLog(SkillsCollection.class);

   SkillRules rules = new SkillRules();

   @XmlElement(name = "Skill")
   ArrayList<Skill> skills = new ArrayList<Skill>();


   /**
    * Instantiates a new skill collection with no managed skills or class skills.
    */
   public SkillsCollection()
   {

   }


   /**
    * This method returns the current skills managed in the collection.
    * 
    * @return array of skills managed in the collection
    */
   public Skill[] getSkills()
   {
      synchronized (skills) {
         return skills.toArray(new Skill[skills.size()]);
      }
   }


   public boolean hasSkill(Skill skill)
   {
      synchronized (skills) {
         return skills.contains(skill);
      }
   }


   /**
    * @return the rules
    */
   public SkillRules getRules()
   {
      return rules;
   }


   /**
    * @param rules the rules to set
    */
   @XmlElement(name = "SkillRules", required = true)
   public void setRules(SkillRules rules)
   {
      this.rules = rules;
   }


   /**
    * @return the classSkillBonus
    */
   public int getClassSkillBonus()
   {
      return rules.classSkillBonus;
   }

}
